package com.ruoyi.web.controller.server;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysDialogueContent;
import com.ruoyi.system.service.ISysDialogueContentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 对话内容Controller
 * 
 * @author ruoyi
 * @date 2025-03-09
 */
@RestController
@RequestMapping("/system/content")
public class SysDialogueContentController extends BaseController
{
    @Autowired
    private ISysDialogueContentService sysDialogueContentService;

    /**
     * 查询对话内容列表
     */
    @GetMapping("/list")
    public TableDataInfo list(SysDialogueContent sysDialogueContent)
    {
        startPage();
        List<SysDialogueContent> list = sysDialogueContentService.selectSysDialogueContentList(sysDialogueContent);
        return getDataTable(list);
    }

    @GetMapping("/getCurrentDialogueContentInfoList")
    public TableDataInfo getCurrentDialogueContentInfoList(SysDialogueContent sysDialogueContent) {
        startPage();
        List<SysDialogueContent> list = sysDialogueContentService.selectSysDialogueContentList(sysDialogueContent);
        return getDataTable(list);
    }

    /**
     * 导出对话内容列表
     */
    @Log(title = "对话内容", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysDialogueContent sysDialogueContent)
    {
        List<SysDialogueContent> list = sysDialogueContentService.selectSysDialogueContentList(sysDialogueContent);
        ExcelUtil<SysDialogueContent> util = new ExcelUtil<SysDialogueContent>(SysDialogueContent.class);
        util.exportExcel(response, list, "对话内容数据");
    }

    /**
     * 获取对话内容详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysDialogueContentService.selectSysDialogueContentById(id));
    }

    /**
     * 新增对话内容
     */
    @Log(title = "对话内容", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysDialogueContent sysDialogueContent)
    {
        return toAjax(sysDialogueContentService.insertSysDialogueContent(sysDialogueContent));
    }

    /**
     * 修改对话内容
     */
    @Log(title = "对话内容", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysDialogueContent sysDialogueContent)
    {
        return toAjax(sysDialogueContentService.updateSysDialogueContent(sysDialogueContent));
    }

    /**
     * 删除对话内容
     */
    @Log(title = "对话内容", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysDialogueContentService.deleteSysDialogueContentByIds(ids));
    }
}
